
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;

public class Atmtest extends JFrame {
    private LogonPanel logonPanel = new LogonPanel(this);
    private LoginPanel loginPanel = new LoginPanel(this);
    private MenuPanel menuPanel = new MenuPanel(this);
    private Find find = new Find(this);
    private Get get = new Get(this);
    private Modify modify = new Modify(this);
    private Save save = new Save(this);
    private Log log = new Log(this);
    private Transfer transfer = new Transfer(this);
    private ArrayList<User> users = new ArrayList<>();
    private int ID;
    private Image bgImg = Util.getImage("/img/background.jpg");
    private CardLayout cardLayout = new CardLayout();
    private User user;

    public Atmtest() {
        intly();
        this.setContentPane(new JPanel() {
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(bgImg, 0, 0, 1024, 768, this);
            }
        });
        this.setLayout(cardLayout);
        this.add("login", loginPanel);
        this.add("menu", menuPanel);
        this.add("logon", logonPanel);
        this.add("find", find);
        this.add("get", get);
        this.add("modify", modify);
        this.add("save", save);
        this.add("log", log);
        this.add("transfer",transfer);
        this.setSize(1024, 768);
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setVisible(true);
    }

    public void switchPanel(String name) {
        cardLayout.show(this.getContentPane(), name);
    }

    public void intly() {
        users.add(new User("zhangsan", "123123", 1231231));
        users.add(new User("lisi", "123123", 1231));
        users.add(new User("wangwu", "123123", 11231));
        users.add(new User("zhaoliu", "123123", 12311));
        users.add(new User("wanger", "123123", 123231));
    }

    public static void main(String[] args) {
        new Atmtest();
    }


    public Get getGet() {
        return get;
    }

    public void setGet(Get get) {
        this.get = get;
    }

    public Find getFind() {
        return find;
    }

    public void setFind(Find find) {
        this.find = find;
    }

    public Modify getModify() {
        return modify;
    }

    public void setModify(Modify modify) {
        this.modify = modify;
    }

    public ArrayList<User> getUsers() {
        return users;
    }

    public void setUsers(ArrayList<User> users) {
        this.users = users;
    }

    public int getID() {
        return ID;
    }

    public void setID(int ID) {
        this.ID = ID;
    }

    public Save getSave() {
        return save;
    }

    public void setSave(Save save) {
        this.save = save;
    }
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Transfer getTransfer() {
        return transfer;
    }

    public void setTransfer(Transfer transfer) {
        this.transfer = transfer;
    }
}